package org.blogwu.learn.functionalformula.chapter1.demo1;

import java.util.Arrays;

public class Main {
    public static void main(String[] args) {
//        FunctionalInterFace f=(int i)->{
//            return i*i*i;
//        };
//        System.out.println(f.getIt(2));
        int[] i1 = {0, 1, 2, 2, 3, 0, 4, 2};
        int[] i2 = {0, 1, 2, 2, 2, 3, 0, 4, 2};
//        System.out.println(removeElement(i2,2));
        System.out.println(removeElement(i2, 0));
    }

    public static int removeElement(int[] nums, int val) {
        int next = 0;
        int len = 0;
        int index = -1;

        for (int i = 0; i < nums.length; i++) {
            if (nums[i] == val) {
                if (index == -1) {
                    index = i;
                } else {

                }
                System.out.println("in:" + i);
                continue;
            }
            if (index >= 0) {
                nums[index] = nums[i];
                index++;
            }
            next++;
        }
        System.out.println(Arrays.toString(nums));
        return next;
    }
}

